Skip to content

feat(vehicles): expose managed seat metadata and occupancy - #371

Merged
ifBars merged 2 commits into
stablefrom
feat/294-vehicle-seats
Oct 19, 2026
Merged

ifBars merged 2 commits into
stablefrom
feat/294-vehicle-seats

Conversation

@ifBars

@ifBars ifBars commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Closes #294.

Adds LandVehicle.Seats as a shared, read-only collection of VehicleSeatInfo objects in native array order. Each seat exposes its index, driver metadata, live occupancy, a nullable managed Player occupant, and OccupantChanged(previous, current).

Notifications observe the generated RpcLogic___SetSeatOccupant_* mutation by verified signature: native observer/target readers bypass the outer SetSeatOccupant method. Assignment notifications run after the native mutation, suppress native identity no-ops, preserve transitions whose managed arguments are both null, and isolate subscriber failures. A per-update observation handles player destruction without an assignment. Vehicle destruction and scene/deinitialization cleanup invalidate retained seats and release subscribers without synthesizing exits.

Compatibility

  • Additive public surface only: LandVehicle.Seats, VehicleSeatInfo, its four read-only properties, and its event. Existing vehicle members, including writable LandVehicle.IsOccupied, remain unchanged.
  • Occupants resolve through Player.All; no native player/seat types are exposed. No entry/ejection/reservation controls, new RPCs, IDs, save formats, or network payload changes.
  • ApiCompat against a source build of exact target base afc8b5a passes, including parameter-name and attribute rules. Focused contract checks also retain the legacy writable property.
  • Seat objects live for the vehicle/scene. Resolve seats again after scene changes. Native assignments notify synchronously; destruction-only occupancy changes notify on the next API update.

Validation

Check MonoMelon Il2CppMelon
Restore and solution build, local deployment disabled Pass Pass
Full contract suite 818 passed 781 passed
New focused seat contracts 6 passed 6 passed
Live loaded-save single-player probe Pass Pass
Live two-peer probe Pass Pass

DocFX build passes (four unresolved dependency-reference warnings); public API documentation coverage is 82.56% (minimum 80%). git diff --check passes.

Live probes use isolated regular-game 0.4.7f12 installs (Mono Alternate and public IL2CPP), disposable copies of a completed save, and local Steam emulation for peer sessions. They exercise probe-driven native seat assignments, metadata/order, shared wrappers, immutable collections, callback state/timing, duplicate suppression, subscriber isolation, driver/passenger transitions, replicated host/client observations, disconnect cleanup, unavailable managed-player conversion, vehicle destruction, scene cleanup, and reload. These are automated native-path probes, not manual vehicle-entry/UI testing or real Steam matchmaking certification.

No proprietary assemblies, decompiled code, game assets, smoke implementations, fixtures, logs, or generated evidence are included in this PR. No version bump or release is included.

Summary by CodeRabbit

  • New Features
    • Added a read-only vehicle seat collection with seat indices, driver-seat status, occupancy, and managed occupant details.
    • Seat occupant changes trigger notifications when native occupant identity changes, even if the occupant cannot be resolved to a player.
  • Bug Fixes
    • Seat data refreshes as occupants change and is cleared when vehicles are destroyed or scenes change, preventing stale information.
    • Vehicles without available seat data return an empty collection.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: be43fb00-5784-4b94-a874-8a9a18a4db09
📥 Commits

Reviewing files that changed from the base of the PR and between 985450a and eedd4e7.

📒 Files selected for processing: 5
  • S1API/Internal/Patches/LandVehiclePatches.cs
  • S1API/Internal/Patches/VehicleSeatPatches.cs
  • S1API/Internal/Vehicles/VehicleSeats.cs
  • S1API/S1API.cs
  • S1API/Vehicles/VehicleSeatInfo.cs
🚧 Files skipped from review as they are similar to previous changes: 5
  • S1API/Internal/Patches/VehicleSeatPatches.cs
  • S1API/Internal/Patches/LandVehiclePatches.cs
  • S1API/S1API.cs
  • S1API/Internal/Vehicles/VehicleSeats.cs
  • S1API/Vehicles/VehicleSeatInfo.cs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The change adds a managed vehicle-seat API with seat metadata, occupant state, and occupant-change notifications. Internal caching and lifecycle hooks manage seat objects. A Harmony patch refreshes occupancy after native seat-occupant updates.

Changes: Vehicle seat API and occupancy

Layer / File(s) Summary
Managed seat contract
S1API/Vehicles/LandVehicle.cs, S1API/Vehicles/VehicleSeatInfo.cs, S1API.Tests/Vehicles/VehicleSeatApiTests.cs
LandVehicle.Seats exposes a read-only list of managed seat information. VehicleSeatInfo provides seat metadata, occupancy properties, and an occupant-change event. Tests check the public surface.
Seat cache and lifecycle
S1API/Internal/Vehicles/VehicleSeats.cs, S1API/S1API.cs, S1API/Internal/Patches/LandVehiclePatches.cs, S1API/Vehicles/VehicleSeatInfo.cs, S1API.Tests/Vehicles/VehicleSeatApiTests.cs
VehicleSeats caches seat lists and invalidates them during vehicle destruction, mod deinitialization, and scene unload. The update hook ticks the cache. Tests cover invalidation and unavailable vehicles.
Occupant refresh and notifications
S1API/Internal/Patches/VehicleSeatPatches.cs, S1API/Vehicles/VehicleSeatInfo.cs, S1API.Tests/Vehicles/VehicleSeatApiTests.cs
A platform-conditional Harmony patch refreshes occupancy after the generated seat-occupant method runs. VehicleSeatInfo compares native occupant identity, resolves managed players, and dispatches change notifications. Tests cover patch selection and notification behavior.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant LandVehicle
  participant VehicleSeats
  participant VehicleSeatPatches
  participant VehicleSeatInfo
  LandVehicle->>VehicleSeats: Get seat list
  VehicleSeats->>VehicleSeatInfo: Create and cache seat information
  VehicleSeatPatches->>VehicleSeats: Refresh vehicle seat after occupant RPC
  VehicleSeats->>VehicleSeatInfo: Refresh occupant state
  VehicleSeatInfo->>VehicleSeatInfo: Resolve managed occupant and notify subscribers
Loading
Merge Risk: ⚪ Minimal · up to eedd4

This adds a managed read-only seat API for land vehicles without changing existing vehicle members. No concrete merge-blocking risk was identified in the supplied context.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: exposing managed vehicle seat metadata and occupancy.
Description check Passed The description provides the linked issue, scope, compatibility impact, validation results, runtime evidence, and documentation status. It omits the explicit contributor checklist and separate Summary…
Linked Issues check Passed Issue #294 is active and directly linked. LandVehicle.Seats provides a read-only collection in native order. VehicleSeatInfo provides the seat index, driver status, live occupancy, managed `Player…
Out of Scope Changes check Passed The changes remain within issue #294. The cache, mutation patch, lifecycle hooks, public API, and focused tests support seat metadata, occupancy, notifications, or required cleanup. The reported chang…
Full details: Description check

Explanation

The description provides the linked issue, scope, compatibility impact, validation results, runtime evidence, and documentation status. It omits the explicit contributor checklist and separate Summary, Mono, IL2CPP, Runtime evidence, and Documentation headings, but the required information is mostly present.

Full details: Linked Issues check

Explanation

Issue #294 is active and directly linked. LandVehicle.Seats provides a read-only collection in native order. VehicleSeatInfo provides the seat index, driver status, live occupancy, managed Player? occupant, and OccupantChanged. The implementation preserves empty-slot indices, avoids native types, observes generated seat mutations, handles unavailable wrappers, disconnects, destruction, scene cleanup, and subscriber isolation. The reported MonoMelon and Il2CppMelon checks cover the required transitions and cleanup.

Full details: Out of Scope Changes check

Explanation

The changes remain within issue #294. The cache, mutation patch, lifecycle hooks, public API, and focused tests support seat metadata, occupancy, notifications, or required cleanup. The reported changes add no forced entry, ejection, reservation, remote-player control, direct RPC access, save format, or network payload. No unrelated change is demonstrated.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🤖 Completed: Generate docstrings for PR #371 — View commit eedd4e7

@ifBars ifBars self-assigned this Oct 19, 2026
@ifBars ifBars added the enhancement New feature or request label Oct 19, 2026
@ifBars
ifBars merged commit c9ac103 into stable Oct 19, 2026
5 checks passed
@ifBars
ifBars deleted the feat/294-vehicle-seats branch October 19, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Expose vehicle seat metadata and occupancy

1 participant